home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / smaltalk / gnu_st.lha / gnu_st / smalltalk-1.1.1 / mstoop.h < prev    next >
C/C++ Source or Header  |  1991-09-12  |  4KB  |  162 lines

  1. /***********************************************************************
  2.  *
  3.  *    Object Table declarations.
  4.  *
  5.  ***********************************************************************/
  6.  
  7. /***********************************************************************
  8.  *
  9.  * Copyright (C) 1990, 1991 Free Software Foundation, Inc.
  10.  * Written by Steve Byrne.
  11.  *
  12.  * This file is part of GNU Smalltalk.
  13.  *
  14.  * GNU Smalltalk is free software; you can redistribute it and/or modify it
  15.  * under the terms of the GNU General Public License as published by the Free
  16.  * Software Foundation; either version 1, or (at your option) any later 
  17.  * version.
  18.  * 
  19.  * GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT
  20.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
  21.  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  22.  * more details.
  23.  * 
  24.  * You should have received a copy of the GNU General Public License along with
  25.  * GNU Smalltalk; see the file COPYING.  If not, write to the Free Software
  26.  * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  
  27.  *
  28.  ***********************************************************************/
  29.  
  30.  
  31. /*
  32.  *    Change Log
  33.  * ============================================================================
  34.  * Author      Date       Change 
  35.  * sbyrne     8 Apr 90      Changed oopFree to oopValid to better reflect the
  36.  *              semantics.
  37.  *
  38.  * sbyrne    13 Jan 89      Created.
  39.  *
  40.  */
  41.  
  42.  
  43. #ifndef __MSTOOP__
  44. #define __MSTOOP__
  45.  
  46. #define INLINE_MACROS
  47.  
  48. /* The number of OOPs in the system.  This is exclusive of Character, True,
  49.    False, and UndefinedObject (nil) oops, which are built-ins. */
  50. #define OOP_TABLE_SIZE        (10240 * 8) /* for the nonce, then back to 4 */
  51.  
  52. #define NUM_CHAR_OBJECTS    256
  53. #define CHAR_OBJECT_BASE    OOP_TABLE_SIZE
  54. #define NUM_BUILTIN_OBJECTS    3
  55. #define BUILTIN_OBJECT_BASE    (CHAR_OBJECT_BASE + NUM_CHAR_OBJECTS)
  56.  
  57. #define nilOOPIndex        (BUILTIN_OBJECT_BASE + 0)
  58. #define trueOOPIndex        (BUILTIN_OBJECT_BASE + 1)
  59. #define falseOOPIndex        (BUILTIN_OBJECT_BASE + 2)
  60.  
  61. #define TOTAL_OOP_TABLE_SLOTS \
  62.   ( OOP_TABLE_SIZE + NUM_CHAR_OBJECTS + NUM_BUILTIN_OBJECTS )
  63.  
  64. /*
  65.  * Given a number of bytes "x", return the number of 32 bit words
  66.  * needed to represent that object, rounded up to the nearest 32 bit
  67.  * word boundary.
  68.  */
  69. #define ROUNDED_WORDS(x) \
  70.   (((x) + sizeof(long) - 1) / sizeof(long))
  71.  
  72. #define GCIsOn() \
  73.   (gcState)
  74.  
  75. #define inToSpace(oop) \
  76.   ((oop)->inSpace == toSpace)
  77.  
  78. #define inFromSpace(oop) \
  79.   ((oop)->inSpace == fromSpace)
  80.  
  81. #define prepareToStore(destOOP, srcOOP) \
  82. { \
  83.   if (inToSpace(destOOP) && isOOP(srcOOP) && inFromSpace(srcOOP)) { \
  84.     moveOOP(srcOOP); \
  85.   } \
  86. }
  87.  
  88. #define maybeMoveOOPMac(oop) \
  89. { \
  90.   if (!isInt(oop) && inFromSpace(oop)) { \
  91.     moveOOP(oop); \
  92.   } \
  93. }
  94.  
  95. #define clearGCFlipFlagsMac() \
  96.   gcFlipCounter = 0
  97.  
  98. #define oopAtMac(index) \
  99.   ( &oopTable[index] )
  100.  
  101. #define oopAvailableMac(index) \
  102.   ( oopTable[index].isFree )
  103.  
  104. #ifdef INLINE_MACROS
  105.  
  106. #define maybeMoveOOP    maybeMoveOOPMac
  107. #define clearGCFlipFlags clearGCFlipFlagsMac
  108. #define oopAt        oopAtMac
  109. #define oopAvailable    oopAvailableMac
  110.  
  111. #else
  112.  
  113. extern void        maybeMoveOOP(), clearGCFlipFlags();
  114. extern OOP        oopAt();
  115. extern Boolean        oopAvailable();
  116.  
  117. #endif /* INLINE_MACROS */
  118.  
  119. typedef struct CharObjectStruct {
  120.   OBJ_HEADER;
  121. #ifdef BIG_ENDIAN
  122.   Byte        charVal;
  123.   Byte        dummy[3];    /* filler */
  124. #else
  125.   Byte        dummy[3];    /* filler */
  126.   Byte        charVal;    /* probably not necessary to care about
  127.                    ordering here */
  128. #endif
  129. } CharObject;
  130.  
  131. struct NilObjectStruct {
  132.   OBJ_HEADER;
  133. };
  134.  
  135. struct BooleanObjectStruct {
  136.   OBJ_HEADER;
  137.   OOP        booleanValue;
  138. };
  139.  
  140. extern CharObject        charObjectTable[];
  141. extern struct NilObjectStruct     nilObject;
  142. extern struct BooleanObjectStruct booleanObjects[];
  143. extern OOP            freeOOPs;
  144. extern int            numFreeOOPs;
  145. extern char            toSpace, fromSpace;
  146. extern Boolean            gcFlipped, gcState, gcMessage;
  147. extern int            gcFlipCounter;
  148.  
  149. extern OOP            allocOOP(), charOOPAt(), findAnInstance();
  150. extern void            initOOP(), setOOPAt(), swapObjects(), 
  151.                 fixupMetaclassObjects(), moveOOP(), gcOn(),
  152.                 setGCState(), gcFlip(), 
  153.                 setSpaceInfo();
  154. extern Byte            charOOPValue();
  155. extern Object            allocObj(), curSpaceAddr();
  156. extern Boolean            oopIndexValid(), oopValid(), gcOff();
  157. extern long            oopIndex();
  158.  
  159. extern struct OOPStruct    oopTable[];
  160.  
  161. #endif /* __MSTOOP__ */
  162.